package 剑指offer;

public class _33二叉搜索树的后序遍历序列 {
    public boolean verifyPostorder(int[] postorder) {
        return postorder(postorder,0,postorder.length - 1);
    }
    public boolean postorder(int[] postorder,int i,int j){
        if(i >= j){
            return true;
        }
        int p = i;
        while (postorder[p] < postorder[j]){
            p++;
        }
        int m = p;
        while (postorder[p] > postorder[j]){
            p++;
        }
        return p == j && postorder(postorder,i,m-1) && postorder(postorder,m,j);
    }
}
